<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>005</title>
	</head>
	<body>
		<script type="text/javascript">
			//定义构造函数
			function People(name,sex,age) {
				this.name = name;
				this.sex = sex;
				this.age = age;
			}
			
			//使用People.prototype属性添加方法，并且也不需要在函数中定义函数名
			People.prototype.say = function() {
				console.log("你好...");
			}
			
			//实例化对象
			var xiaoming = new People("小明","男",12);
			var xiaohong = new People("小红","女",12);
			//这两个对象调用同一个类中同一个属性上的同一个方法
			xiaoming.say();
			xiaohong.say();
			
			console.log(xiaoming.say === xiaohong.say);
			//原型的作用：实例化共享方法
			//构造函数的方法要写在原型上
			
		</script>
	</body>
</html>
